<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>

<script type="text/javascript" src="js/jquery-3.4.1.min.js"></script>
<link rel="stylesheet" href="css/login.css">

<script>
	function login() {
		var userName=document.getElementById("userName").value;
		var password=document.getElementById("password").value;
		var userType=document.getElementById("userType").value;
		console.log(userName+"---"+password+"---"+userType);
		$.ajax({
			url : 'user/login',
			method : 'post',
			data : {
				"userName": userName,
				"password": password,
				"userType": userType
			}, 
			dataType : 'text',
			success : function(res) {
					if(res==1){
						alert("登录成功");
						if(userType=="0")
							// 管理员页面
							window.location.replace("managerIndex.html"); 
						else
							// 门卫页面
							window.location.replace("./html/doorkeeperIndex.html");
					}else
						alert("登录失败")
			},
			error : function(data) {
				 alert("操作失败！！！");
			}
		});
	}
</script>
</head>

<body>
      
	<div class="login">
	    <h3 style="">停车场管理系统</h3>
		<div class="login-Content">
			<div class="loginItem">
				<span><label for="userName">用户名：</label></span> <input type="text"
					name="userName" id="userName">
			</div>
			<div class="loginItem">
				<span><label for="password">密码：</label></span> <input
					type="password" name="password" id="password">
			</div>
		</div>
		<div class="loginItem">
			<select id="userType">
				<option value="0">管理员</option>
				<option value="1" selected="selected">门卫</option>
			</select>
		</div>
		<div class="btn">
			<span> <input type="button" class="loginBtn" name="login"
				id="login" value="登 录" onclick="login()">
			</span>
		</div>
	</div>

</body>


</html>

